package ${package.Entity};

<#list table.importPackages as pkg>
    import ${pkg};
</#list>
<#if swagger>
    import io.swagger.v3.oas.annotations.media.Schema;
</#if>
<#if entityLombokModel>
    import lombok.Data;
    <#if chainModel>
        import lombok.experimental.Accessors;
    </#if>
</#if>
import com.fasterxml.jackson.annotation.JsonFormat;

/**
* <p>
    * ${table.comment!}
    * </p>
* @author ${author}
* @since ${date}
*/
<#if entityLombokModel>
    @Data
    <#if chainModel>
        @Accessors(chain = true)
    </#if>
</#if>
<#if table.convert>
    @TableName("${schemaName}${table.name}")
</#if>

<#if superEntityClass??>
    public class ${entity} extends ${superEntityClass} <#if activeRecord> <${entity}> </#if> {

<#elseif activeRecord>
    public class ${entity} extends Model<${entity}> {

<#elseif entitySerialVersionUID>
    public class ${entity} implements Serializable {

<#else>
    public class ${entity} {
</#if>
<#if entitySerialVersionUID>
    <#assign timestamp = .now?long>
    <#assign serialVersionUID = timestamp?string('0')>
    private static final long serialVersionUID = ${serialVersionUID}L;
</#if>
<#-- ----------  BEGIN 字段循环遍历  ---------->
<#list table.fields as field>
    <#if field.keyFlag>
        <#assign keyPropertyName="${field.propertyName}"/>
    </#if>
    <#if field.comment!?length gt 0>

    </#if>
    <#if field.keyFlag>
    <#-- 主键 -->
        <#if field.keyIdentityFlag>
            /**
            * "${field.comment}"
            */
            @TableId(value = "${field.annotationColumnName}", type = IdType.AUTO)
            <#if swagger>
                @Schema(description = "${field.comment}")
            </#if>
        <#elseif idType??>
            /**
            * "${field.comment}"
            */
            @TableId(value = "${field.annotationColumnName}", type = IdType.${idType})
            <#if swagger>
                @Schema(description = "${field.comment}")
            </#if>
        <#elseif field.convert>
            /**
            * "${field.comment}"
            */
            @TableId("${field.annotationColumnName}")
            @Schema(description = "${field.comment}")
        </#if>
    <#-- 普通字段 -->
    <#elseif field.fill??>
    <#-- -----   存在字段填充设置   ----->
        <#if field.convert>
            @Schema(description = "${field.comment}")
        <#else>
            @Schema(description = "${field.comment}")
        </#if>
    <#elseif field.convert>
        /**
        * "${field.comment}"
        */
        @Schema(description = "${field.comment}")
    </#if>
<#-- 乐观锁注解 -->
    <#if field.versionField>
        @Version
    </#if>
<#-- 逻辑删除注解 -->
    <#if field.logicDeleteField>
        @TableLogic
    </#if>
<#-- 日期注解 -->
    <#if field.propertyType == "Date">
        @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    </#if>
    private ${field.propertyType} ${field.propertyName};

</#list>
<#------------  END 字段循环遍历  ---------->
<#if !entityLombokModel>
    <#list table.fields as field>
        <#if field.propertyType == "boolean">
            <#assign getprefix="is"/>
        <#else>
            <#assign getprefix="get"/>
        </#if>
        public ${field.propertyType} ${getprefix}${field.capitalName}() {
        return ${field.propertyName};
        }
        <#if chainModel>
            public ${entity} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
        <#else>
            public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {

        </#if>
        this.${field.propertyName} = ${field.propertyName};
        <#if chainModel>
            return this;
        </#if>
        }
    </#list>
</#if>
<#if entityColumnConstant>
    <#list table.fields as field>
        public static final String ${field.name?upper_case} = "${field.name}";
    </#list>
</#if>
<#if activeRecord>
    @Override
    public Serializable pkVal() {
    <#if keyPropertyName??>
        return this.${keyPropertyName};
    <#else>
        return null;
    </#if>
    }

</#if>
<#if !entityLombokModel>
    @Override
    public String toString() {
    return "${entity}{" +
    <#list table.fields as field>
        <#if field_index == 0> "${field.propertyName}=" + ${field.propertyName} +
        <#else> ", ${field.propertyName}=" + ${field.propertyName} +
        </#if>
    </#list>
    " } ";
    }
</#if>
}